<template>
	<view>
		<swiper :indicator-dots="false" :autoplay="false" :current="current" :duration="300" @change="changescroll"
			style="width: 100%;height: 100vh;">
			<swiper-item>
				<view class="swiper-item">
					<Home></Home>
				</view>
			</swiper-item>
			<swiper-item>
				<view class="swiper-item">
					<Order></Order>
				</view>
			</swiper-item>
			<swiper-item>
				<view class="swiper-item">
					<Me></Me>
				</view>
			</swiper-item>
		</swiper>
		<TabBar :current="current" @changetab="changetab"></TabBar>
	</view>
</template>

<script>
	import Home from "@/pages/main/home.vue"
	import Order from "@/pages/order/order.vue"
	import Me from "@/pages/me/me.vue"
	import TabBar from "@/components/TabBar.vue"

	import {
		baseURL
	} from '@/api/base.js'; //导入接口的前缀地址
	export default {
		components: {
			Home,
			Order,
			Me,
			TabBar,
		},
		data() {
			return {
				current: this.$store.state.current
			};
		},
		onLoad(e) {
			if(e.current){
				this.current = e.current;
				this.$store.commit('setCurrent', e.current);
			}
			uni.setNavigationBarTitle({
				title: this.$t('Home')
			})
		},

		methods: {
			changetab(e) {
				this.current = e;
				this.$store.commit('setCurrent', e);
			},
			changescroll(e) {
				this.current = e.detail.current;
				this.$store.commit('setCurrent', e.detail.current);
				if (this.current == 0) {

					uni.setNavigationBarTitle({
						title: this.$t('Home')
					})
				} else if (this.current == 1) {
					uni.setNavigationBarTitle({
						title: this.$t('Order')
					})
				} else {
					uni.setNavigationBarTitle({
						title: this.$t('Me')
					})
				}
			},
			onShareAppMessage() {
				return {
					title: 'Sinchay点餐',
					path: '/pages/main/main',
					imageUrl: ''
				}
			},
			onShareTimeline() {
				return {
					title: 'Sinchay点餐',
					path: '/pages/main/main',
					imageUrl: ''
				}
			}

		}
	}
</script>

<style lang="scss">
	.swiper-item {
		width: 100%;
		height: 100vh;
	}
</style>